package com.face.facemap.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.face.facemap.entity.Emp;
import com.face.facemap.service.EmpService;
import com.face.facemap.util.PageUtil;

@Controller
public class EmpController {
	
	Logger logger=Logger.getLogger(EmpController.class);
	@Resource
	private EmpService empService;
	
	@RequestMapping(value="getEmpList",method=RequestMethod.GET)
	public String getEmpList(Integer index,Model model){
		PageUtil page=new PageUtil();
		if(index!=null){
			page.setStartRow(page.getStart(index));
			page.setIndex(index);	
			page.setTotalCount(empService.getEmpCount());
		}else{
			logger.debug("index 参数不能为null");
		}
		List<Emp> empList=empService.getEmpList(page);
		for(Emp emp:empList){
			System.out.println(emp.getEname());
		}
		model.addAttribute("empList", empList);
		model.addAttribute("page", page);	
		return "/emp_find";
	}

	
}
